import * as constants from './MutationTypes'

export default {
  [constants.SET_USER_INFO] (state, data) {
    state.userInfo = data.userInfo
    state.departments = data.departments || []
    state.userInfo.departments = state.departments.map(i => i['departmentName'] || '').join(',')
    state.authorityInfo = data.authorityInfo.map(i => i['code'])
  },
  [constants.UPDATE_USER_INFO] (state, data) {
    Object.assign(state.userInfo, data)
  },
  [constants.UPDATE_AUTHORITY_INFO] (state, data) {
    state.authorityInfo = data
  }
}
